package com.wxapp.pay.service.pay;

import com.esotericsoftware.minlog.Log;
import com.wxapp.common.core.filter.except.ThrowMyException;
import com.wxapp.pay.api.pojo.pojo.vo.order.QOrderInfoVo;
import org.springframework.context.ApplicationEvent;

/**
 * @author lgl
 * 微信支付
 */
//@Slf4j
public abstract class BasePay {
    /**
     * 获取类型
     */
    protected abstract String getType();

    /**
     * 执行pay 方法
     */
    protected abstract String invoke(QOrderInfoVo vo, ApplicationEvent... event) throws Exception;

    /**
     * 执行pay 方法
     */
    public String executePay(QOrderInfoVo vo, ApplicationEvent... event) throws ThrowMyException {
        try {
            return invoke(vo,event);
        } catch (Exception e) {
            Log.error(e.getMessage(), e);
            throw new ThrowMyException("支付失败:" + e.getMessage());
        }
    }
}
